//
// Created by Administrator on 2021/11/25.
//

#ifndef INC_03_MRENDER_FRAMWORK_OBJECT_H
#define INC_03_MRENDER_FRAMWORK_OBJECT_H
#include <string>
#include <cassert>
#include "Log.h"
#include "../utils/StringUtil.h"

//安全释放内存
#define SAFE_DELETE(p)       { if(p) { delete (p);     (p)=NULL; } }
#define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p);   (p)=NULL; } }
#define SAFE_RELEASE(p)      { if(p) { (p)->Release(); (p)=NULL; } }
//获得文件名
#define GET_CLASS(fp) StringUtil::getClassName(fp)

class Object {
public:
    virtual bool equals(Object o);
    virtual std::string toString();
};

//反射
//函数指针
typedef Object* (*create_fun)();
void RegisterFactoryCreate(create_fun, String className);

#define DECLARE_CLASS_CREATE(class_name) static Object* CreateClass## class_name ()
#define IMPL_CLASS_CREATE(class_name)  static Object* CreateClass## class_name (){  return new class_name; }
#define REG_CLASS_CREATE(class_name) RegisterFactoryCreate(class_name::CreateClass## class_name, #class_name)

#endif //INC_03_MRENDER_FRAMWORK_OBJECT_H
